Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
Is there a way to tell Vim what to do every time I'm about to close a file? Specifically I am asking because I don't want to make a call to :mkview all the time, especially since I forget it most of the time...
So can I tell Vim to call :loadview when I open a file and :mkview when I close it?
The best answers are often in Vim's help, if you know what to search for. In this case, one possible solution is at :h :loadview:
To automatically save and restore views for *.c files:
au BufWinLeave *.c mkview
au BufWinEnter *.c silent loadview
You can modify this to suit your own needs. To make it apply to all filetypes, use * instead of *.c. To make this happen at Vim startup and exit, use the events VimLeave and VimEnter instead of BufWinLeave and BufWinEnter.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I'm very new to vim and might be asking a very dumb question, but I've added a keyboard shortcut to switch between tabs, but when I do switch this happens
Instead of the tab indicator moving it moves everything, I don't know how to explain this with words but I think you get my point with the gif. Is there any way of changing this to a normal tab switching like browsers do?
The shortcuts I'm using are:
:noremap <C-n> :bnext<CR>
:noremap <C-n> :bprevious<CR>
Just fixed it by changing from bnext and bprevious to tabn and tabp....
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I have already setup vim size to 4 in ~/.vimrc. It is working when I enter tab, but the original file display tab in size 8. How to make them all in size 4?
Thank you,
:verbose setlocal tabstop? softtabstop? expandtab? shiftwidth?
will show you the current indent settings (and where it got defined). Since these are buffer-local settings, it's not enough to set this once in your ~/.vimrc. Several filetype plugins change these indent settings. (Though typically not 'tabstop', but rather 'softtabstop'.
You could avoid that by turning off filetype plugins altogether (drop :filetype plugin on from your ~/.vimrc), but it's better to selectively override this in the after directory.
Put your :setlocal ... commands into ~/.vim/after/ftplugin/{filetype}.vim. (This requires that you have :filetype plugin on; use of the after directory allows you to override any default filetype settings done by $VIMRUNTIME/ftplugin/{filetype}.vim.) Alternatively, you could define an :autocmd FileType {filetype\} ... directly in your ~/.vimrc, but this tends to become unwieldy once you have many customizations.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
In vim, the latex-suite plugin is for tex filetype. I want to apply the convenience of vim latex-suite plugin for markdown filetype. How can I do it?
EDIT: I want to use markdown syntax to take notes. But It's not convenient for me to type formula in the markdown file. It will be very convenient If the latex-suite macros/shortcuts can be used in markdown file(with the markdown highlight syntax).
In vim I set this
:set ft=tex
:set syntax=markdown
and then I have all the latex-suite macros and shortcuts working, while the syntax highlighting is set to markdown.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I am new to VIM and I use the command
qa
to start recording the operations in register a and the following command
q
to stop saving. And the following command to use the operations in a:
#a
But the problem is that, when I close the VIM, all these registers are deleted. Is there any way to save these operations and use it later in other sessions of VIM?
If you don't run Vim in compatible mode (only masochists would run Vim in compatible mode), named registers, "a to "z, are remembered across sessions.
Do you run Vim without a ~/.vimrc? What is the output of :set viminfo? :set compatible? (with the question mark)?
You could create a map in your .vimrc
map <F2> [your macro]
If the macro is already at register 'a', you can also use it, that is, instead of repeating [your macro], you can type <C-r>a while in insert mode.
You could also try marvim.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I have a bunch of files in (project)/src and (project)/inc.
When I press <C-x><C-f> vim should give me suggestions about filenames from there but I couldn't find how to set the directories it searches in.
The documentation I read says only that <C-p> and <C-n> moves inside the list but nothing about calibrating the search path.
set autochdir
automatically sets the "current directory" to the one containing the current file. Put it in your vimrc, enjoy life.
Its the pwd or the path from where the vim was launched.Its not configurable.
Although a new feature called path-support will be available in vim soon:
http://vimdoc.sourceforge.net/htmldoc/options.html#%27path%27
That might help you configure more.
In the meantime try these vim plugins:
FuzzyFinder
http://www.vim.org/scripts/script.php?script%5Fid=1984
zvim
https://bitbucket.org/ZyX_I/zvim
t-command
http://www.vim.org/scripts/script.php?script_id=3025
Or you can write your own vim plugin.
Refer:
http://vim.wikia.com/wiki/Searching_for_files_in_a_directory_listing
And
http://vim.wikia.com/wiki/Source_vimrc_and_use_tags_in_a_parent_directory
This is what I've done to solve the problem, seems much more easier than #askmish solution.
Edit vimrc and add this mapping :
map <F4> :cd %:h<CR>
from now on, press F4 to switch to current directory.
Now when you press <C-X><C-F> you can see a list of all files in your current working directory.