<p>Programming in vim I often go search for something, yank it, then go back to where I was, insert it, modify it.</p>

<p>The problem is that after I search and find, I need to MANUALLY find my way back to where I was.</p>

<p>Is there an automatic way to go back to where I was when I initiated my last search?</p>

[{'answer_id': 53924, 'author': 'Mark Biek', 'author_id': 305, 'author_profile': 'https://Stackoverflow.com/users/305', 'pm_score': 6, 'selected': False, 'text': "<p>I've always done by it setting a mark.</p>\n\n<ol>\n<li><p>In command-mode, press <strong><kbd>m</kbd><em>[letter]</em></strong>.  For example, <kbd>m</kbd><kbd>a</kbd> sets a mark at the current line using <strong>a</strong> as the mark identifier.</p></li>\n<li><p>To get back to the mark press <strong><kbd>'</kbd> [letter]</strong>.  For example, <kbd>'</kbd><kbd>a</kbd> takes you back to the line mark set in step 1.  To get back to the column position of the row where you marked the line, use <kbd>`</kbd><kbd>a</kbd> (<strong>back-tick <em>[letter]</em></strong>).</p></li>\n</ol>\n\n<p>To see all of the marks that currently set, type <strong><code>:marks</code></strong>.</p>\n\n<hr>\n\n<p>On a slightly unrelated note, I just discovered another nifty thing about marks.</p>\n\n<p>Let's say you jump to mark <strong>b</strong> by doing <kbd>m</kbd><kbd>b</kbd>.  Vim automatically sets the mark <kbd>'</kbd> (that's a single-quote) to be whichever line you were on before jumping to mark <strong>b</strong>.</p>\n\n<p>That means you can do <kbd>'</kbd><kbd>b</kbd> to jump to that mark, then do <kbd>''</kbd> (2 single-quotes) to jump back to wherever you were before.</p>\n\n<p>I discovered this accidentally using the <code>:marks</code> command, which shows a list of all marks.</p>\n"}, {'answer_id': 53926, 'author': 'Paul Tomblin', 'author_id': 3333, 'author_profile': 'https://Stackoverflow.com/users/3333', 'pm_score': 3, 'selected': False, 'text': "<p>The simplest way is to set a mark, with <code>m[letter]</code>, then go back to it with <code>'[letter]</code></p>\n"}, {'answer_id': 53929, 'author': 'Agnel Kurian', 'author_id': 45603, 'author_profile': 'https://Stackoverflow.com/users/45603', 'pm_score': 10, 'selected': True, 'text': "<p><kbd>Ctrl</kbd>+<kbd>O</kbd> takes me to the previous location. Don't know about location before the search.</p>\n\n<p>Edit: Also, <kbd>`</kbd><kbd>.</kbd> will take you to the last change you made.</p>\n"}, {'answer_id': 84117, 'author': 'Max Cantor', 'author_id': 16034, 'author_profile': 'https://Stackoverflow.com/users/16034', 'pm_score': 7, 'selected': False, 'text': "<p>Use <code>``</code> to jump back to the exact position you were in before you searched/jumped, or <code>''</code> to jump back to the start of the line you were on before you searched/jumped.</p>\n"}, {'answer_id': 138943, 'author': 'André', 'author_id': 9683, 'author_profile': 'https://Stackoverflow.com/users/9683', 'pm_score': 5, 'selected': False, 'text': '<p>You really should read <code>:help jumplist</code> it explains all of this very well.</p>\n'}, {'answer_id': 10392263, 'author': 'Ethan Zhang', 'author_id': 619292, 'author_profile': 'https://Stackoverflow.com/users/619292', 'pm_score': 3, 'selected': False, 'text': '<p>I use this one:</p>\n\n<pre><code>nnoremap / ms/\nnnoremap ? ms?\n</code></pre>\n\n<p>Then if I search something by using <code>/</code> or <code>?</code>, I can go back quickly by <code>`s</code>. You could replace the letter <code>s</code> to any letter you like.</p>\n'}, {'answer_id': 12706072, 'author': 'sale', 'author_id': 1716702, 'author_profile': 'https://Stackoverflow.com/users/1716702', 'pm_score': 5, 'selected': False, 'text': '<p><kbd>CTRL+O</kbd> and <kbd>CTRL+I</kbd>, for jumping back and forward.</p>\n'}]
['https://Stackoverflow.com/questions/53911', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4639/']